Refactor Tools_View #369
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new password_generator_views.py module to pull the password-generator flow out of the previously “huge” tools_views area, aiming to improve organization and maintainability.
Changes:
- Added a dedicated
ToolsPassword*view module for password generation, entropy collection, review, and save flows. - Wired in support paths for multiple password formats (Diceware, Dice Rolls, Hex/Base64/Base85, custom charset) and multiple entropy sources (camera, system RNG, BIP85).
- Added Seedkeeper save support for generated passwords.
Comment on lines
+29
to
+31
| from seedsigner.models.seed import Seed | ||
| from seedsigner.models.settings_definition import SettingsConstants | ||
| from .view import View, Destination, BackStackView, MainMenuView |
Comment on lines
+299
to
+322
| if selected == dice: | ||
| if self.password_type == PASSWORD_TYPE_DICE_ROLLS and self.dice_sides is not None and self.roll_count is not None: | ||
| return Destination( | ||
| ToolsPasswordDiceEntryView, | ||
| view_args=dict( | ||
| password_type=self.password_type, | ||
| random_options=self.random_options, | ||
| strength_bits=self.strength_bits, | ||
| total_rolls=self.roll_count, | ||
| word_count=None, | ||
| entropy_source=PASSWORD_ENTROPY_DICE, | ||
| dice_sides=self.dice_sides, | ||
| ), | ||
| skip_current_view=True, | ||
| ) | ||
| return Destination( | ||
| ToolsPasswordDiceRollCountView, | ||
| view_args=dict( | ||
| password_type=self.password_type, | ||
| strength_bits=self.strength_bits, | ||
| random_options=self.random_options, | ||
| entropy_source=PASSWORD_ENTROPY_DICE, | ||
| ), | ||
| ) |
Copilot AI
added a commit
that referenced
this pull request
Jun 13, 2026
- Move BIP85/GPG imports from tools_views to gpg_views - Remove duplicate local imports of _bip85_key_type_choices - Update tests and tools to use correct import paths Fixes import errors in: - tests/test_bip85_gpg.py - tests/test_bip85_bipsea_vectors.py - tests/test_bip85_pgp_cli.py - tools/bip85_pgp.py
Closed
12 tasks
Add pythonpath=["src"] to pyproject.toml and remove redundant pip install . from CI workflow. Rework view imports and exports so internal helpers (including underscore-prefixed symbols and shared TextQR/BIP85 helpers) are explicitly re-exported from tools_views for backward compatibility. Propagate shared helpers across gpg_views, password_generator_views, and smartcard_views (also fix a logging call and add hmac, seedkeeper utils, and seed-related imports). Update tests to patch the appropriate modules (smartcard_views and password_generator_views) so monkeypatches target the modules that actually import the helpers.
Add a Testing guidance section to AGENTS.md describing how to run pytest, expected platform-dependent failures, a star-import caveat for underscore-prefixed names, and guidance for adding tests. Re-export _check_future_key_creation from gpg_views in tools_views.py for backward compatibility with tests and callers. Update tests/test_gpg_message.py: improve _msys2_path to detect the installed gpg via shutil.which and only convert Windows paths to MSYS2 style when the GPG binary is from Git-for-Windows/MSYS2, leaving native Gpg4win paths unchanged to avoid writable keyring errors.
Define a MIN_RSA_KEY_BITS = 2048 constant in gpg_views.py (used by bip85_rsa_from_root) to enforce a minimum RSA key size. Update AGENTS.md to refresh the test table (clarify satochip test entry) and adjust the baseline test counts to 716 passing, 134 skipped, 7 failing, noting satochip tests require physical hardware.
Add missing imports and helpers to smartcard_views: binascii (hexlify/unhexlify), embit.descriptor.Descriptor, and embit_utils plus XprvSeed from models. Also reorder/clean imports and expose SeedExportXpubVerifyAddressView. Update unit test to patch HDKey in the smartcard_views module instead of tools_views to match the refactor. These changes prepare the smartcard view code for using embit utilities and the Xprv-backed seed model.
Refactor tests/test_bip85_gpg.py to import and reference seedsigner.views.gpg_views rather than the older tools_views alias. Update monkeypatch.setattr targets, class instantiations, and BIP85_DATA assertions to use gpg_views. Add seed_bytes attribute to test SeedObj classes and make a few related minor adjustments (imports and subprocess/microsd references) to ensure tests target the correct module.
Add multiple .cap applet binaries under javacard-cap/ to ship built applets. Refactor smartcard views: move the GlobalPlatform presence check into the BUILD_APPLETS path and show a clear warning when DIY tools are not available. Rewrite ToolsDIYInstallAppletView to gather .cap files from both the internal repo and the MicroSD javacard-cap directory, merge results, prefix duplicate names with (Internal)/(MicroSD) to disambiguate, and handle missing/unreadable MicroSD gracefully. Also add a docstring and improve selection logging.
Add a new javacard-cap/javacard-cap.sha256 manifest containing SHA256 sums for various CAP files. Update smartcard_views.py to detect the DIY toolchain by checking for the ANT executable path (ant/bin/ant) instead of looking for gp.jar, with host-specific path locations adjusted accordingly and the existence check updated to use the ant path.
Extracts the internal javacard-cap path into a module-level _get_internal_cap_dir() function and updates ToolsDIYInstallAppletView to use it. Tests updated to monkeypatch this helper (and adjust the logger target) so the test suite can isolate from the real filesystem. No behavioral change beyond making the internal cap directory retrieval testable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was getting huge :)